package com.yzt.zhuju.dialog;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.yzt.zhuju.R;
import com.yzt.p_base.utils.ToastUtil;

/**
 * author : bob
 * date   : 2022/11/30
 * desc   :
 */
public class EditDialogFragment extends CenterBaseDialog {

    private EditText mContentEt;
    private OnInputListener listener;

    public void setListener(OnInputListener listener) {
        this.listener = listener;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_edit_content;
    }

    @Override
    public void bindView(View view) {
        mContentEt = view.findViewById(R.id.content_et);
        view.findViewById(R.id.submit_tv).setOnClickListener(v -> {
            String trim = mContentEt.getText().toString().trim();
            if (TextUtils.isEmpty(trim)) {
                ToastUtil.showMessage(getString(R.string.input_invite_code));
                return;
            }
            listener.inputContent(trim);
            dismiss();
        });

    }

    public interface OnInputListener {
        void inputContent(String content);
    }
}